package itanty.aop3;

import com.itanty.exception.UserExistException;
import com.itanty.exception.UserNotExistException;

/**
 * @date 2025/9/23
 */
public class UserServiceImpl implements UserService {
    @Override
    public String register(String username, String password, String phone, String address) throws UserExistException {
        System.out.println("正在注册");
        if("admin".equals(username)){
            throw new UserExistException("该用户已经被注册");
        }
        return "用户名可用";
    }

    @Override
    public String login(String username, String password) throws UserNotExistException {
        System.out.println("正在登录");
        if("admin".equals(username) && "123456".equals(password)){
            return "登录成功";
        }
        throw new UserNotExistException("用户名或密码错误");
    }
}
